func (m *custom{{.upperStartCamelObject}}Inter) Delete(ctx context.Context,session sqlx.Session, {{.lowerStartCamelPrimaryKey}} any) (int64, error) {
    var result sql.Result
    var err error

	{{if .withCache}}{{if .containsIndexCache}}data, err:=m.FindOne(ctx, {{.lowerStartCamelPrimaryKey}})
	if err!=nil{
		return 0, err
	}

    {{end}}	{{.keys}}
    result, err {{if .containsIndexCache}}={{else}}={{end}} m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
		query := fmt.Sprintf("delete from %s where {{.originalPrimaryKey}} = {{if .postgreSql}}$1{{else}}?{{end}}", m.table)
        if session != nil{
            return session.ExecCtx(ctx,query, {{.lowerStartCamelPrimaryKey}})
        }else{
            return conn.ExecCtx(ctx, query, {{.lowerStartCamelPrimaryKey}})
        }

	}, {{.keyValues}}){{else}}query := fmt.Sprintf("delete from %s where {{.originalPrimaryKey}} = {{if .postgreSql}}$1{{else}}?{{end}}", m.table)
		if session != nil{
		    result,err = session.ExecCtx(ctx, query, {{.lowerStartCamelPrimaryKey}})
		}else{
		    result,err =m.conn.ExecCtx(ctx, query, {{.lowerStartCamelPrimaryKey}})
		}
	{{end}}
	if err != nil {
        return 0, err
    }
    affected, err := result.RowsAffected();
    if err != nil {
        return affected,err
    }
    if affected == 0 {
        return affected,NotModified
    }
    return affected,nil
}
